// Desc: 环墫判断工具类
export default class EnvUtils {
    /**
     * 判断当前是否运行在微信小程序端
     * @returns {boolean}
     */
    static isWechatMiniProgram() {
        const systemInfo = uni.getSystemInfoSync();
        return systemInfo.platform === 'devtools' || systemInfo.platform === 'ios' || systemInfo.platform === 'android';
    }

    /**
     * 判断当前是否运行在 App 端
     * @returns {boolean}
     */
    static isApp() {
        const systemInfo = uni.getSystemInfoSync();
        return systemInfo.platform === 'android' || systemInfo.platform === 'ios';
    }

    /**
     * 获取当前运行环境
     * @returns {string} 'wechatMiniProgram' | 'app' | 'unknown'
     */
    static getCurrentEnv() {
        if (this.isWechatMiniProgram()) {
            return 'wechatMiniProgram';
        } else if (this.isApp()) {
            return 'app';
        } else {
            return 'unknown';
        }
    }
}